<template>
  <div>
    <basic-container>
      <div class="app-container">
        <el-form :model="queryParams" :rules="rules" ref="queryForm" size="small" :inline="true">
          <!-- <div>
            <el-form-item :label="title">
              <el-input v-model="queryParams.sn" placeholder="请输入壳体码" style="width: 200px;"></el-input>
              <el-input v-model="queryParams.code" placeholder="请输入总码" style="width: 200px; margin: 0 10px;"></el-input>
              <el-input v-model="queryParams.grade" placeholder="请输入等级" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button :disabled="isDisabled" type="primary" icon="el-icon-edit" size="mini" @click="handleQuery">绑定</el-button>
            </el-form-item>
          </div>
          <div>
            <el-form-item label="壳体总码删除">
              <el-input v-model="menuMessTwo" placeholder="请输入壳体总码" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button :disabled="menudis" type="primary" icon="el-icon-delete" size="mini" @click="handleDelet">删除</el-button>
            </el-form-item>
          </div> -->
          <div>
         
            <el-form-item :label="titleLab">
              <el-input v-model="maxNub" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxNub')"></el-input>
            </el-form-item>
            <el-form-item :label="titleLabtwo">
              <el-input v-model="maxTwo" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxTwo')"></el-input>
            </el-form-item>
            <el-form-item :label="titleLabwhere">
              <el-input v-model="maxthere" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxthere')"></el-input>
            </el-form-item>



            <el-form-item :label="titleFoue">
              <el-input v-model="maxFour" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxFour')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax3">
              <el-input v-model="max3" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max3')"></el-input>
            </el-form-item>

           

            <el-form-item :label="titleMax8">
              <el-input v-model="max8" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max8')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax10">
              <el-input v-model="max10" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max10')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax13">
              <el-input v-model="max13" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max13')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax16">
              <el-input v-model="max16" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max16')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax17a">
              <el-input v-model="max17a" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max17a')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax19">
              <el-input v-model="max19" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max19')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax22">
              <el-input v-model="max22" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max22')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax23">
              <el-input v-model="max23" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max23')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax24">
              <el-input v-model="max24" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max24')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax37">
              <el-input v-model="max37" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max37')"></el-input>
            </el-form-item>

            <el-form-item :label="titleMax41">
              <el-input v-model="max41" placeholder="请输入次数" style="width: 200px;" @input="validateInput('max41')"></el-input>
            </el-form-item>

            <el-form-item>
              <el-button  type="primary" icon="el-icon-check" size="mini" @click="DefiniteMdification">确定</el-button>
            </el-form-item>

          </div>
        </el-form>
      </div>
    </basic-container>
  </div>
</template>

<script>
import { bindingCode, delCode, grtUsersall, eidMinAMax } from "@/api/view2";

export default {
  data() {
    return {
      loading: false,
      titleLab:'',
      titleLabtwo:'',
      titleLabwhere:'',
      titleFoue:'',
      minNub: '',
      maxNub: '',
      maxTwo:'',
      maxthere:'',
      maxFour:'',
      eidMaxnum: '',
      eidMinnum: '',
      title: "壳体总码绑定",
      queryParams: {
        sn: '',
        code: '',
        grade: ''
      },
      menuMessTwo: '',
  
      rules: {
        sn: [{ required: true, message: "壳体码不能为空", trigger: "blur" }],
        code: [{ required: true, message: "总码不能为空", trigger: "blur" }],
        grade: [{ required: true, message: "等级不能为空", trigger: "blur" }]
      },
      titleMax3: '',
      titleMax13: '',
      titleMax10: '',
      titleMax16: '',
      titleMax17a: '',
      titleMax19: '',
      titleMax22: '',
      titleMax23: '',
      titleMax24: '',
      titleMax37: 'YB08-37 NG最大返工次数',
      titleMax41: 'YB08-41 NG最大返工次数',
     
      titleMax8: '',
      max3: '',
      max13: '',
      max10: '',
      max16: '',
      max17a: '',
      max19: '',
      max22: '',
      max23: '',
      max24: '',
      max37: '',
      max41: '',
     
      max8: ''
    };
  },
  created() {
    this.getMaxAndMIn();
  },
  computed: {
    isDisabled() {
      return !this.queryParams.sn.trim() || !this.queryParams.code.trim() || !this.queryParams.grade.trim();
    },
    menudis() {
      return !this.menuMessTwo.trim();
    },

  },
  methods: {
    handleQuery() {
      bindingCode(this.queryParams).then(res => {
        console.log(res);
        this.$message({
          message: "绑定成功",
          type: "success"
        });
        this.queryParams.sn = '';
        this.queryParams.code = '';
        this.queryParams.grade = '';
      });
    },
    validateInput(field) {
      this[field] = this[field].replace(/[^0-9]/g, '');
    },
    getMaxAndMIn() {
      grtUsersall().then(res => {
        console.log(res);
        this.titleLab = res.data.doc.interval1516
        this.titleLabtwo = res.data.doc.interval1819
        this.titleLabwhere = res.data.doc.interval2022
        this.titleFoue = res.data.doc.max28ab;
        this.maxNub = res.data.interval1516;
        this.maxTwo = res.data.interval1818;
        this.maxthere = res.data.interval2022;
        this.maxFour = res.data.max28ab;
        this.titleMax3 = res.data.doc.max3;
        this.titleMax13 = res.data.doc.max13;
        this.titleMax10 = res.data.doc.max10;
        this.titleMax16 = res.data.doc.max16;
        this.titleMax17a = res.data.doc.max17a;
        this.titleMax19 = res.data.doc.max19;
        this.titleMax22 = res.data.doc.max22;
        this.titleMax23 = res.data.doc.max23;
        this.titleMax24 = res.data.doc.max24;
        this.titleMax37 = res.data.doc.max37;
        this.titleMax41 = res.data.doc.max41;
       
        this.titleMax8 = res.data.doc.max8;
        
        this.max3 = res.data.max3;
        this.max13 = res.data.max13;
        this.max10 = res.data.max10;
        this.max16 = res.data.max16;
        this.max17a = res.data.max17a;
        this.max19 = res.data.max19;
        this.max22 = res.data.max22;
        this.max23 = res.data.max23;
        this.max24 = res.data.max24;
        this.max37 = res.data.max37;
        this.max41 = res.data.max41;
        this.max8 = res.data.max8;
      });
    },
    DefiniteMdification() {
      let data = {
        interval1516: Number(this.maxNub),
        interval1819: Number(this.maxTwo),
        interval2022: Number(this.maxthere),
        max28ab: Number(this.maxFour),
        max3: Number(this.max3),
        max13: Number(this.max13),
        max10: Number(this.max10),
        max16: Number(this.max16),
        max17a: Number(this.max17a),
        max19: Number(this.max19),
        max22: Number(this.max22),
        max23: Number(this.max23),
        max24: Number(this.max24),
        max37: Number(this.max37),
        max41: Number(this.max41),
      
        max8: Number(this.max8)
      };
      eidMinAMax(data).then(res => {
          console.log(res);
        this.$message({
          message: "修改成功",
          type: "success"
        });
        this.getMaxAndMIn();
      });
    },
    handleDelet() {
      let data = {
        sn: this.menuMessTwo
      };
      delCode(data).then(res => {
        console.log(res);
        this.$message({
          message: "删除成功",
          type: "success"
        });
      });
    }
  }
};
</script>

<style>
/* 添加你的样式 */
</style>